<?php
/**
 * @fileoverview    前端投放行为日志接口
 * @author          shaopu
 * @date            Thu Jun 14 07:26:56 GMT 2012
 * @copyright       sina meila
 */
include_once '../__global.php';
include_once(SERVER_ROOT_PATH.'/include/config/ml_actionCode.php');

define('ML_SHAREPRODUCT_SINAWEIBO' , 1);
define('ML_SHAREPRODUCT_QQWEIBO' , 2);
define('ML_SHAREPRODUCT_QZONE' , 3);
define('ML_SHAREPRODUCT_RENREN' , 4);
define('ML_SHAREPRODUCT_KAIXIN' , 5);
define('ML_SHAREPRODUCT_TAOBAO' , 6);

class aj_actlog extends ml_controller {
    
    private $act;
    private $dest;
    private $type;
    private $dest_uid;
    private $ext;
    private $act2actcode = array(
        'share' => ML_SINAACTCODE_VIEW_SHARE,
    );
    
    function initParam() {
        $this->act = $this->input('act');
        $this->dest = $this->input('dest');
        $this->type = (int)$this->input('type');
        $this->dest_uid = (int)$this->input('dest_uid');
        $this->ext = $this->input('ext');
    }
    function checkParam() {
        
        if(!isset($this->act2actcode[$this->act]))
            $this->api_output(ML_RCODE_PARAM);
        $this->check_referer();
    }
    
    function main() {
        $act_code = $this->act2actcode[$this->act];
        parse_str($this->ext , $aExt);
        
        //分享
        if($act_code == ML_SINAACTCODE_VIEW_SHARE)
        {
            $aExt['Product'] = ML_SHAREPRODUCT_SINAWEIBO;
            $aExt['src_type'] = $this->type;
            if(ml_tool_resid::is_resid($this->dest))
            {
                $oContent = new ml_model_dbContent();
                $rs = $oContent->get_by_rid($this->dest);
                $data = $oContent->get_data();
                $a = parse_url($data['gd_info']['gd_url']);
                $aExt['longurl'] = urlencode($data['gd_info']['gd_url']);
                $aExt['product_source'] = $a['host'];
            }
        }
        ml_tool_actionlog::add_other_action($this->__visitor['uid'] , $act_code , $this->dest , $this->dest_uid , $aExt);
        $this->api_output(ML_RCODE_SUCC);
    }
}

new aj_actlog();